package com.mssh.login.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mssh.entity.table.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 熳殊沙华
 * @Date: 2025/03/25/14:58
 * @Description:
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {

    /**
     * 根据用户id获取对应的所有角色的标识
     * @return 标识集合
     */
    List<String> findRoleLabelsList(@Param("userId") long userId);

    /**
     * 根据用户id查询资源菜单标识
     * @param userId 用户id
     * @return
     */
    List<String> findPermissionsList(@Param("userId") long userId);

    /**
     * 根据账号查询用户
     * @param account
     * @return
     */
    @Select("SELECT * FROM `sys_user` where account = #{account} and enable = 1")
    SysUser getSysUserByAccount(@Param("account") String account);

    /**
     * 根据手机号查询用户信息
     * @param telphone
     * @return
     */
    @Select("SELECT * FROM `sys_user` where telphone = #{telphone} and enable = 1")
    SysUser getSysUserByTelphone(@Param("telphone") String telphone);
}
